home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-06 | 7.5 KB | 273 lines | [TEXT/KAHL] |
- // ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
- // • Program: FrameAnim
- // • File: Dialogs.c
- // •
- // • Copyright © 1993 by Scott B. Steinman, O.D., Ph.D. All Rights Reserved.
- // ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
-
- #include "FrameAnim.h"
-
- // • ------------------ External Globals ----------------------------------
-
- extern CWindowPtr gMainWindow; // • From Main.c file
- extern Settings gSettings; // • From Main.c file
- extern Flags gFlags; // • From Main.c file
-
- // • ------------------ Film Control Dialog Box ---------------------------
-
- void
- FilmDlg( void )
- // •
- // • Dialog box that appears before filming.
- {
- DialogRecord dStorage;
- DialogPtr theDialog = NullPointer;
- Handle numFramesItem = NullHandle,
- frameDelayItem = NullHandle,
- sizeDiffItem = NullHandle;
- Rect box;
- long frames, delay, sizeDiff;
- short itemHit, kind;
- Boolean notProper = false;
- Str255 numFramesText, frameDelayText, sizeDiffText;
-
- gFlags.cancel = false;
- frames = gSettings.numFrames;
- delay = gSettings.frameDelay;
- sizeDiff = gSettings.sizeDiff;
- NumToString( frames, &numFramesText );
- NumToString( delay, &frameDelayText );
- NumToString( sizeDiff, &sizeDiffText );
-
- theDialog = GetNewDialog( kFilmDlgID, &dStorage, (WindowPtr) kMoveToFront );
-
- GetDItem( theDialog, kFilmDlgNumFrames, &kind, &numFramesItem, &box );
- SetIText( numFramesItem, &numFramesText );
- GetDItem( theDialog, kFilmDlgFrameDelay, &kind, &frameDelayItem, &box );
- SetIText( frameDelayItem, &frameDelayText );
- GetDItem( theDialog, kFilmDlgSizeDiff, &kind, &sizeDiffItem, &box );
- SetIText( sizeDiffItem, &sizeDiffText );
-
- do {
- ModalDialog( NullPointer, &itemHit );
- GetIText( numFramesItem, &numFramesText );
- GetIText( frameDelayItem, &frameDelayText );
- GetIText( sizeDiffItem, &sizeDiffText );
- } while ( itemHit != kFilmDlgGoAhead && itemHit != kFilmDlgCancel );
-
- CloseDialog( theDialog );
-
- if (itemHit == kFilmDlgCancel)
- gFlags.cancel = true;
- else {
- StringToNum( &numFramesText, &frames );
- StringToNum( &frameDelayText, &delay );
- StringToNum( &sizeDiffText, &sizeDiff );
-
- // • Make sure all values are within their proper ranges!
-
- if (sizeDiff <= 0 || sizeDiff > kMaxSizeDiff)
- notProper = true;
- if (frames <= 0 || frames > kMaxFrames)
- notProper = true;
- if (delay < 1)
- notProper = true;
-
- if (notProper == true) { // • Call Dialog again if not proper
- SysBeep( 1 );
- FilmDlg();
- }
- else {
- gSettings.numFrames = frames;
- gSettings.frameDelay = delay;
- gSettings.sizeDiff = sizeDiff;
-
- EnableItem( GetMHandle( kAnimID ), kPlayItem );
- }
- }
- }
-
- // • ------------------ Frame Size Dialog Box -----------------------------
-
- void
- FrameSzDlg( void )
- // •
- // • Dialog box that is called when frame dimensions are to be changed.
- {
- DialogRecord dStorage;
- DialogPtr theDialog = NullPointer;
- Handle diamItem = NullHandle;
- Rect box;
- long diam;
- short itemHit, kind;
- Boolean notProper = false;
- Str255 diamText;
-
- gFlags.cancel = false;
- diam = gSettings.frameSize;
- NumToString( diam, &diamText );
-
- theDialog = GetNewDialog( kFrameSzDlgID, &dStorage, (WindowPtr) kMoveToFront );
-
- GetDItem( theDialog, kFrameSzDlgDiam, &kind, &diamItem, &box );
- SetIText( diamItem, &diamText );
-
- do {
- ModalDialog( NullPointer, &itemHit );
- GetIText( diamItem, &diamText );
- } while (itemHit != kFrameSzDlgGoAhead && itemHit != kFrameSzDlgCancel);
-
- CloseDialog( theDialog );
-
- if (itemHit == kFrameSzDlgCancel)
- gFlags.cancel = true;
- else {
- StringToNum( &diamText, &diam );
-
- if (diam < 20) {
- SysBeep( 1 );
- FrameSzDlg();
- }
- else {
- gSettings.frameSize = diam;
-
- // • Force user to rebuild GWorlds
- DisableItem( GetMHandle( kAnimID ), kPlayItem );
- }
- }
- }
-
- // • ------------------ Gray Scale Dialog Box -----------------------------
-
- void
- GrayDlg( void )
- // •
- // • This is the dialog box that is called when you want the gray scale info.
- // • The user may choose the gray value of the background or target.
- {
- DialogRecord dStorage;
- DialogPtr theDialog = NullPointer;
- Handle targetGrayItem = NullHandle,
- bkgndGrayItem = NullHandle;
- Rect box;
- long tGray, bGray;
- short itemHit, kind, i;
- Boolean notProper = false;
- Str255 targetGrayText, bkgndGrayText;
-
- gFlags.cancel = false;
- bGray = gSettings.bkgndGray;
- tGray = gSettings.targetGray;
- NumToString( bGray, &bkgndGrayText );
- NumToString( tGray, &targetGrayText );
-
- theDialog = GetNewDialog( kGrayDlgID, &dStorage, (WindowPtr) kMoveToFront );
-
- GetDItem( theDialog, kGrayDlgBkgndGray, &kind, &bkgndGrayItem, &box );
- SetIText( bkgndGrayItem, &bkgndGrayText );
- GetDItem( theDialog, kGrayDlgTargetGray, &kind, &targetGrayItem, &box );
- SetIText( targetGrayItem, &targetGrayText );
-
- do {
- ModalDialog( NullPointer, &itemHit );
- GetIText( bkgndGrayItem, &bkgndGrayText );
- GetIText( targetGrayItem, &targetGrayText );
-
- } while ( itemHit != kGrayDlgGoAhead && itemHit != kGrayDlgCancel );
-
- CloseDialog( theDialog );
-
- if (itemHit == kGrayDlgCancel)
- gFlags.cancel = true;
- else {
- StringToNum( &bkgndGrayText, &bGray );
- StringToNum( &targetGrayText, &tGray );
-
- // • Make sure all values are within their proper ranges!
-
- if (bGray < 0 || bGray > 255)
- notProper = true;
- if (tGray < 0 || tGray > 255)
- notProper = true;
-
- if (notProper == true) { // • Call Dialog again if not proper
- SysBeep( 1 );
- GrayDlg();
- }
- else {
- // • Force user to rebuild GWorlds
- DisableItem( GetMHandle( kAnimID ), kPlayItem );
-
- gSettings.bkgndGray = bGray;
- gSettings.targetGray = tGray;
-
- UpdateWindowColors(); // • Reset palettes if colors changed
- PmBackColor( kPalBkgnd );
- EraseRect( &gMainWindow->portRect ); // • Clear the area completely
- }
- }
- }
-
- // • ------------------ Set Display Monitor Dialog Box --------------------
-
- void
- MonitorDlg( void )
- // •
- // • Dialog box that is called to set choice of display monitor.
- {
- DialogRecord dStorage;
- DialogPtr theDialog = NullPointer;
- Handle theHandle = NullHandle;
- ControlHandle mainMonRadio = NullHandle,
- secMonRadio = NullHandle;
- Rect box;
- short mainMon = 0, secMon = 0, thePart, itemHit, kind, index;
- Boolean notProper = false;
-
- gFlags.cancel = false;
- switch (gSettings.displayMonitor) {
- case kMain: mainMon = 1; break;
- case kSecondary: secMon = 1; break;
- }
-
- theDialog = GetNewDialog( kMonitorDlgID, &dStorage, (WindowPtr) kMoveToFront );
-
- GetDItem( theDialog, kMonitorDlgMainMon, &kind, &theHandle, &box );
- mainMonRadio = (ControlHandle) theHandle;
- SetCtlValue( mainMonRadio, mainMon );
- GetDItem( theDialog, kMonitorDlgSecMon, &kind, &theHandle, &box );
- secMonRadio = (ControlHandle) theHandle;
- SetCtlValue( secMonRadio, secMon );
-
- do {
- ModalDialog( NullPointer, &itemHit );
-
- // • Make the radio buttons switch around.
-
- switch (itemHit) {
- case kMonitorDlgMainMon:
- mainMon = 1;
- secMon = 0;
- break;
- case kMonitorDlgSecMon:
- secMon = 1;
- mainMon = 0;
- break;
- }
- SetCtlValue( mainMonRadio, mainMon );
- SetCtlValue( secMonRadio, secMon );
- } while ( itemHit != kMonitorDlgGoAhead && itemHit != kMonitorDlgCancel );
-
- CloseDialog( theDialog );
-
- if (itemHit == kMonitorDlgCancel) {
- gFlags.cancel = true;
- gSettings.displayMonitor = kMain;
- }
- else {
- if (mainMon == 1) gSettings.displayMonitor = kMain;
- else if (secMon == 1) gSettings.displayMonitor = kSecondary;
- }
- }
-
-